# -*- encoding: utf-8 -*-
"""
@version: 1.0
@author: yang ming
@contact: 122162005@qq.com
@site: http://www.idianjia.com/
@software: PyCharm
@file: client.py
@time: 2016/3/23 10:31
"""
from socket import *

HOST = 'localhost'
PORT = 60000
BUFSIZ = 1024
ADDR = (HOST, PORT)

tcpCliSock = socket(AF_INET, SOCK_STREAM)
tcpCliSock.connect(ADDR)


def client():
    while True:
        data = input("input> ")
        print(data)
        if not data:
            break
        tcpCliSock.send(str(data).encode("utf-8"))

        data = tcpCliSock.recv(BUFSIZ)
        if not data:
            break

        print(data)

    tcpCliSock.close()

if __name__ == "__main__":
    client()
